home *** CD-ROM | disk | FTP | other *** search
-
- ******************************************************************************
- * *
- * HodgePodge: An example Apple IIGS Desktop application *
- * *
- * Written in 65816 Assembler by the Apple IIGS Tools Team *
- * Modified by Ben Koning for "Programmer's Introduction to the Apple IIGS" *
- * *
- * Copyright (c) 1986-87 by Apple Computer, Inc. *
- * *
- * ---------------------------------------------------------------------- *
- * *
- * ASM65816 Code file "EVENT.ASM" -- TaskMaster call; Dispatching to all *
- * other routines; Menu dimming. *
- * *
- ******************************************************************************
-
-
-
- ****************************************************************
- *
- * Event
- *
- * This contains the main event loop.
- *
- ****************************************************************
-
- MainEvent START
- using GlobalData
-
- Again anop
-
- lda QuitFlag ;Has Quit been select?
- bne AllDone ;... if so, stop the loop.
-
- jsr CheckFrontW ;Handle the menu dis/enable
-
- PushWord #0
- PushWord #$FFFF
- PushLong #EventRecord
- _TaskMaster
-
- pla
- beq Again ;No event? loop.
-
- asl a ;Multiply by two...
- tax ;use for index into...
- jsr (TaskTable,x) ;dispatch table to execute events.
-
- bra Again ;Loop.
-
- AllDone rts
-
- TaskTable anop
- ;----------------------------------------------------
- ;
- ; Event manager events
- ;
- dc i'ignore' ; 0 null
- dc i'ignore' ; 1 mouse down
- dc i'ignore' ; 2 mouse up
- dc i'ignore' ; 3 key down
- dc i'ignore' ; 4 undefined
- dc i'ignore' ; 5 auto-key down
- dc i'ignore' ; 6 update event
- dc i'ignore' ; 7 undefined
- dc i'DoActivate' ; 8 activate
- dc i'ignore' ; 9 switch
- dc i'ignore' ; 10 desk acc
- dc i'ignore' ; 11 device driver
- dc i'ignore' ; 12 ap
- dc i'ignore' ; 13 ap
- dc i'ignore' ; 14 ap
- dc i'ignore' ; 15 ap
-
- ;----------------------------------------------------
- ;
- ; Task master events
-
- dc i'ignore' ; 0 in desk
- dc i'DoMenu' ; 1 in MenuBar
- dc i'ignore' ; 2 in system window
- dc i'ignore' ; 3 in content of window
- dc i'ignore' ; 4 in drag
- dc i'ignore' ; 5 in grow
- dc i'DoCloseItem' ; 6 in goaway -- same as "Close" item
- dc i'ignore' ; 7 in zoom
- dc i'ignore' ; 8 in info bar
- dc i'DoMenu' ; 9 in special menu item
- dc i'ignore' ; 10 in OpenNDA
- dc i'ignore' ; 11 in frame
- dc i'ignore' ; in drop
-
- END
-
- ****************************************************************
- *
- * CheckFrontW
- *
- * Checks to see if front window has changed and if
- * so deals with various menu enables and disables.
- * called by main event loop, and activate events.
- *
- ****************************************************************
- CheckFrontW Start
- using MenuData
- using GlobalData
-
- PushLong #0
- _FrontWindow
- PullLong ThisWindow ;get the current front window.
-
- lda ThisWindow ;Check to see if it is
- cmp LastWindow ;still the same window as
- bne Changed ;last time
- lda ThisWindow+2
- cmp LastWindow+2
- bne Changed
-
- Exit1 rts ;No Change No problem....Else.
-
- Changed anop
- lda ThisWindow ;LastWindow := ThisWindow
- sta LastWindow
- lda ThisWindow+2
- sta LastWindow+2
-
- jsr TypeThisW ;set ThisWType=type of the new front win
-
- lda ThisWType ;arriving here, the window has changed.
- cmp LastWType ;it's type may not have changed.
- beq Exit1 ;Branch taken if the latter is true.
-
- !ok so start changing menus
-
- cmp #0 ;is there a front window
- bne ThereIs1 ;take this branch if there is.
-
- jsr SetupForNoW ;if no front window then disable
- bra FinishUp ;various thing I care about and go
- ! ;Finish up
-
- ThereIs1 ANOP
- cmp #1 ;is it a system (Da)
- bne NotSysW ;taken if not.
-
- jsr SetUpForDaW ;else it is a da. do what's needed
- bra FinishUp ;and do the exit stuff
-
- NotSysW jsr SetUpForAppW ;A-reg = Wtype. Go deal w/menu stuff
-
- ! And drop into exit stuff
-
- FinishUp lda NeedToUpdate ;has the menu bar changed
- beq ReallyDone ;taken if not. else
-
- _DrawMenuBar ;we need to re-draw the menu
- stz NeedToUpdate ;and say we did it.
-
- ReallyDone lda ThisWType ;LastWType := ThisWType
- sta LastWType
- rts
-
- * figure out the type of the front window.
- * 0= there is no window. 1 = it's a da window. 2 = App Font Win. 3= App Pic Win.
-
- TypeThisW anop
- lda ThisWindow ;was there a window at all ?
- ora ThisWindow+2
- sta ThisWType ;if no front window then ThisWtype=0
- beq DoneEarly ;taken if there really was no front win
-
- PushWord #0 ;get and save wuther or not
- PushLong ThisWindow ;this is a
- _GetSysWFlag ;system window or not.
- pla
- beq WasApp ;0 means not a sys window
-
- lda #1 ;it's a sys (da) window so
- sta ThisWType ;set lastwtype = 1
- DoneEarly rts
-
- WasApp Anop ;it's an app win. find out what kind.
-
- PushLong #0 ;space for get ref con in a sec
- PushLong ThisWindow ;else I have the window ptr
-
- _GetWrefCon ;get refcon it has handle to data
-
- pla ;recon handle to
- sta Temp ;temp and A/X
- plx
- stx Temp+2
-
- jsr deref ;lock it down for a sec
-
- sta 0
- stx 2
-
- ldy #oFlag ;check if picture
- lda [0],y ;get window type
- beq PicW
-
- lda #2 ;it's a font window so...
- sta ThisWType ;say so and
- bra OuttaHere ;split
-
- PicW lda #3 ;it's a pic window. so
- sta ThisWType ;say so and split.
-
- OuttaHere lda Temp
- ldx Temp+2
- jsr Unlock ;unlock the refcon handle.'
- rts
-
- Temp ds 4
-
-
- ThisWindow ds 4
- LastWindow ds 4
-
- END
-
- ****************************************************************
- *
- * doQuitItem
- *
- * Sets quit flag.
- *
- ****************************************************************
- doQuitItem START
- using GlobalDATA
-
- lda #True
- sta QuitFlag
-
- rts
- END
-
- ******************************************************************
- *
- * DoActivate
- *
- * Handles activation of windows and adjusts the edit meun
- * based on window type.
- *
- ******************************************************************
- DoActivate Start
- using GlobalData
-
- lda EventModifiers
- and #1
- beq end ;don't care about deactivate ?
-
- jsr CheckFrontW
- end rts
- END
-
- ******************************************************************
- *
- * SetUpForAppW
- *
- * Sets the edit menu items up for the application window:
- * that is disabling them. And sets the other file menu items
- * accordingly.
- *
- ******************************************************************
- SetUpForAppW Start
- Using GlobalData
- Using MenuData
-
- PushLong #0 ;get ready to call changeMitems
- PushWord #SaveID ;We gonna do save item. but we need
-
- lda ThisWType ;to figure out whether it should be
- cmp #3 ;enabled or not. is it a font window ?
- bne NoSaveEnable ;if so dont enable the save item.
-
- PushWord #True ;else push true for enable
- bra Cont
-
- NoSaveEnable PushWord #False
-
- Cont PushWord #CloseWID
- PushWord #True
-
- lda PrintAvail
- beq SkipPrint
-
- PushWord #PrintID
- PushWord #True
- PushWord #SetUpID
- PushWord #True
- SkipPrint jsr ChangeMItems
-
- lda LastWType
- cmp #1 ;was it a da last ?
- bne Exit ;if not we don't need to do whats next
-
- PushWord #$0080 ;disable edit menu
- PushWord #EditMenuID
- _SetMenuFlag
- lda #True ;set update flag so I only redraw
- sta NeedToUpdate ;the menu bar once
-
- Exit rts
-
- END
-
- ******************************************************************
- *
- * SetUpForNoW
- *
- * Sets the edit menu items up for the desk acc window:
- * that is enabling edit menu, and close in file menu.
- * accordingly.
- *
- ******************************************************************
- SetUpForNoW START
- Using GlobalData
- Using MenuData
-
- PushLong #0 ;end of list mark first...
- PushWord #SaveID ;disble save
- PushWord #False ;i desire disable.
- PushWord #PrintID
- PushWord #False
- PushWord #SetUpID
- PushWord #False
- PushWord #CloseWID
- PushWord #False ;enable
- jsr ChangeMItems
-
- lda LastWType ;what was it last
- cmp #1 ;was it a da last ?
- bne Exit ;if not we don't need to do whats next
-
- PushWord #$0080 ;disable edit menu
- PushWord #EditMenuID
- _SetMenuFlag
- lda #True ;set update flag so I only redraw
- sta NeedToUpdate ;the menu bar once
-
- Exit rts
- End
-
- ******************************************************************
- *
- * SetUpForDaW
- *
- * Sets the edit menu items up for the desk acc window:
- * that is enabling edit menu, and close in file menu.
- * accordingly.
- *
- ******************************************************************
- SetUpForDaW START
- Using GlobalData
- Using MenuData
-
- PushLong #0 ;end of list mark first...
- PushWord #SaveID ;disble save
- PushWord #False ;i desire disable.
- PushWord #PrintID
- PushWord #False
- PushWord #SetUpID
- PushWord #False
-
- PushWord #CloseWID
- PushWord #True ;enable
- jsr ChangeMItems
-
- lda LastWType ;what was it last
- cmp #1 ;was it a da window last ?
- beq Exit ;if so we don't need to do whats next
-
- PushWord #$ff7f ;enable edit menu
- PushWord #EditMenuID
- _SetMenuFlag
- lda #True ;set update flag so I only redraw
- sta NeedToUpdate ;the menu bar once
-
- Exit rts
-
- END
-
- ******************************************************************
- *
- * ChangeMItems
- *
- * Enables/Disables the various menu items according to the
- * flags pushed on stack.
- *
- * Entry Stack Looks like:
- *
- * 0 ;long indicator of end of items
- * ItemID ;word item id
- * Enable/Disable Flag ;(word) true = enable
- * .
- * ItemID ;word item id
- * Enable/Disable Flag ;(word) true = enable
- * .
- * Return ;word
- * Sp =>
- *
- ******************************************************************
- ChangeMItems Start
-
- PullWord RtaTemp ;save return
-
- Lp lda 3,s ;check for end of list mark
- beq Done ;if so split
-
- pla
- bne DoEnable ;taken if we should enable items
-
- _DisableMItem ;else disable them
- bra Lp ;and start over
-
- DoEnable _EnableMItem ;enable item
- bra Lp ;one more time
-
- Done PullLong ;pull end of list mark
-
- PushWord RtaTemp ;push return address
- rts
-
- RtaTemp ds 2
- EnableFlag ds 2
-
- END
-